import 'dart:convert' show json;

class DownloadData {

  List<DownloadItem> data;

  DownloadData.fromParams({this.data});

  factory DownloadData(jsonStr) => jsonStr == null ? null : jsonStr is String ? new DownloadData.fromJson(json.decode(jsonStr)) : new DownloadData.fromJson(jsonStr);

  DownloadData.fromJson(jsonRes) {
    data = jsonRes['data'] == null ? null : [];

    for (var dataItem in data == null ? [] : jsonRes['data']){
      data.add(dataItem == null ? null : new DownloadItem.fromJson(dataItem));
    }
  }

  @override
  String toString() {
    return '{"data": $data}';
  }
}

class DownloadItem {

  String pictureUrl;

  DownloadItem.fromParams({this.pictureUrl});

  DownloadItem.fromJson(jsonRes) {
    pictureUrl = jsonRes['pictureUrl'];
  }

  @override
  String toString() {
    return '{"pictureUrl": ${pictureUrl != null?'${json.encode(pictureUrl)}':'null'}}';
  }
}

